#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int main()
{
    char arr[10000];
    int count[26], i, j;
    scanf("%s", &arr);
    int len = strlen(arr);
    int Max = 0, Min = len;
    memset(count, 0, sizeof(int) * 26);
    for (i = 0; i < len; i++)
    {
        for (j = 0; j < 26; j++)
        {
            if (arr[i] == 'a' + j)
            {
                count[j]++;
                break;
            }
        }
    }
    for (j = 0; j < 26; j++)
    {
        if (Max < count[j] && count[j] != 0)
            Max = count[j];
        if (Min > count[j] && count[j] != 0)
            Min = count[j];
    }
    printf("%d", Max - Min);
    return 0;
}